#include "stdafx.h"
#include "cppflibinc.h"


using namespace cppflib;
using namespace cppflib::os;
using namespace cppflib::exceptions;

static void __SubThrowABaseException(int t)
{
   cppmempool::MemPoolWrap localPool;
   
   if (t > 100)
      throw BaseException(_S("hello world"), 123);
   else
      throw BaseException(NULL, 123);
}

static void __ThrowABaseException(int t)
{
   cppmempool::MemPoolWrap localPool;

   CFString *pStr = new CFString("10101");

   __SubThrowABaseException(t);
}

static void TestBaseException(void)
{
   cppmempool::MemPoolWrap localPool;
   try {
      __ThrowABaseException(101);
   }
   catch (BaseException exp) {
      assert(exp.GetErrCode() == 123);
   }
}


void TestExceptions(void)
{
   debug::Print(_S("Testing exceptions ...\n"));

   TestBaseException();
}
